<template>
	<view class="admin">
		<comHead :title="'群管理'" :isLeft="true" :isRight="false"></comHead>
		<view class="contentBox">
			<view class="list">
				<view class="list-item">
					<view class="l">
						<view>群聊邀请确认</view>
						<text>启用后，群成员需群主或群管理员确认才能邀请朋友进群。</text>
					</view>
					<view class="r">
						<switch :checked="qunDetail.yao==2?false:true" color=" #0f9dfe" @change="doEditQunQuery"/>
					</view>
				</view>
			</view>
			
			<view class="list">
				<view class="list-item">
					<text class="l">仅群主/群管理员可修改群聊名称</text>
					<view class="r">
						<switch :checked="qunDetail.edit_name==2?false:true" color=" #0f9dfe" @change="doEditQunnameQuery"/>
					</view>
				</view>
			</view>
			
			<view class="list">
				<view class="list-item" @click="comLink('/pages/social/changeQunZhu?id='+id)">
					<text class="l">群主管理权转让</text>
					<view class="r">
						<image src="https://siha.vxmeng.com/static/social/r.png" mode="widthFix"></image>
					</view>
				</view>
				<view class="list-item" @click="comLink('/pages/social/adminList?id='+id)">
					<text class="l">群管理员</text>
					<view class="r">
						<image src="https://siha.vxmeng.com/static/social/r.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
			
			<view class="btn" @click="">
				<text>解散该群聊</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				qunDetail:{},
				id:'',
				editVal:''
			}
		},
		onLoad(options) {
			this.id = options.id
		},
		onShow() {
			this.getQunDetail()
		},
		methods: {
			async doEditQunQuery(e) {
				console.log(e)
				const res = await this.$myRequest({
					url: 'api/qun/doEditQunQuery',
					data: {
						qun_id: this.id,
						status:e?1:2
					}
				})
				if (res.code == 1) {
					console.log(res)
					this.$tools.showTx(res.msg)
				}else{
					this.qunDetail.yao = e?2:1
				}
			},
			async doEditQunnameQuery(e) {
				console.log(e)
				const res = await this.$myRequest({
					url: 'api/qun/doEditQunnameQuery',
					data: {
						qun_id: this.id,
						status:e?1:2
					}
				})
				if (res.code == 1) {
					console.log(res)
					this.$tools.showTx(res.msg)
				}else{
					this.qunDetail.edit_name = e?2:1
				}
			},
			async getQunDetail() {
				const res = await this.$myRequest({
					url: 'api/qun/getQunDetail',
					data: {
						qun_id: this.id,
					}
				})
				if (res.code == 1) {
					console.log(res)
					this.qunDetail = res.data
				}
			},
		}
	}
</script>

<style lang="less" scoped>
.admin{
	width: 100vw;
	height: 100vh;
	color: #fff;
	.contentBox{
		padding: 0 30rpx;
		
		.list{
			margin-bottom: 30rpx;
			padding: 0 30rpx;
			background: linear-gradient(106deg, rgba(34, 34, 34, 0.6) 0%, rgba(30, 36, 44, 0.39) 100%);
			width: 100%;
			border-radius: 20rpx;
			.list-item{
				height: 96rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 100%;
				padding: 20rpx 0;
				border-top: 2rpx solid #292929;
				.l{
					view{
						font-size: 32rpx;
						margin-bottom: 10rpx;
					}
					text{
						font-size: 24rpx;
					}
				}
				.r{
					image{
						width: 48rpx;
						vertical-align: middle;
					}
				}
				&:nth-child(1){
					border: none;
				}
			}
			&:first-child,
			&:nth-child(2){
				.list-item{
					height: auto;
					padding: 32rpx 0;
				}
			}
		}
		
		.btn{
			width: 100%;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			border-radius: 10rpx;
			background: #D62629;
			&.dis{
				background: #767B82;
			}
		}
	}
}
</style>